package cn.admobiletop.adsuyi.adapter.toutiao.util;

import android.os.Build;

import com.bytedance.sdk.openadsdk.TTAdConstant;

import cn.admobiletop.adsuyi.ADSuyiSdk;
import cn.admobiletop.adsuyi.config.ADSuyiConfig;

/**
 * @author ciba
 * @description 描述
 * @date 2019/10/8
 */
public class TTAdUtil {
    public static String getTypeNameByAdType(int adType) {
        switch (adType) {
            case TTAdConstant.INTERACTION_TYPE_DOWNLOAD:
                return "下载安装";
            case TTAdConstant.INTERACTION_TYPE_DIAL:
                return "拨打电话";
            default:
                return "查看详情";
        }
    }

    /**
     * 判断设备api是否为22及以下
     * @return
     */
    public static boolean withoutLowSystem() {
//        return Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT;
        return Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1;
    }

    public static boolean withoutXiaoMiHighSystem() {
        return "xiaomi".equalsIgnoreCase(Build.MANUFACTURER) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
    }

    /**
     * 获取是否需要展示二次提示弹框
     *
     * @return : 网络集合
     */
    public static int getDisplayDownloadTipsDialogType() {
        int downloadTip = ADSuyiSdk.getInstance().getDownloadTip();
        switch (downloadTip) {
            case ADSuyiConfig.DownloadTip.DOWNLOAD_TIP_NOTHING:
                // 下载提示——均不提示
                return TTAdConstant.DOWNLOAD_TYPE_NO_POPUP;
            case ADSuyiConfig.DownloadTip.DOWNLOAD_TIP_MOBILE_TRAFFIC:
                // 下载提示——手机流量提示（4G等非WIFI网络）
                if (NetWorkUtil.isWifi()) {
                    return TTAdConstant.DOWNLOAD_TYPE_NO_POPUP;
                }
                return TTAdConstant.DOWNLOAD_TYPE_POPUP;
            case ADSuyiConfig.DownloadTip.DOWNLOAD_TIP_ALL:
                //下载提示——均提示
                return TTAdConstant.DOWNLOAD_TYPE_POPUP;
            default:
                return TTAdConstant.DOWNLOAD_TYPE_NO_POPUP;
        }
    }
}
